package com.requestfactory.wire;

import java.util.EnumSet;

public enum WireError {
	
	//
	// SKELETON
	//
	WIRE_SKELETON_CANNOT_CREATE_SERVER_INSTANCE(10010000),
	WIRE_SKELETON_CANNOT_REGISTER_DUPLICATE_INTERFACE(10010001),
	WIRE_SKELETON_INTERFACE_NOT_INSTANCEOF_IMPL(10010002),
	//
	// SPI
	//
	WIRE_SPI_UNSUPPORTED_HTTP_METHOD(10020000),
	WIRE_SPI_CANNOT_DESERIALIZE_REQUEST(10020001),
	WIRE_SPI_CANNOT_LOOKUP_SERVICE(10020002),
	WIRE_SPI_CANNOT_LOOKUP_METHOD_SIGNATURE(10020003),
	WIRE_SPI_FATAL_ERROR_NO_RESPONSE(10020004),
	WIRE_SPI_FATAL_ERROR_INVOKATION_FAILED(10020005),
	WIRE_SPI_HTTP_ERROR(10020006),
	WIRE_SPI_IO_ERROR(10020007),
	WIRE_SPI_UNKNOWN_ERROR(10020008),
	WIRE_SPI_CANNOT_DESERIALIZE_RESPONSE(10020009),
	;
	
	
	
	private final int errorCode;
	
	private WireError(int errorCode) {
		this.errorCode = errorCode;
	}

	public int getErrorCode() {
		return errorCode;
	}

	public static WireError valueOf(int errorCode) {
		for(WireError value : EnumSet.allOf(WireError.class)) {
			if(errorCode == value.errorCode) {
				return value;
			}
		}
		return null;
	}

}
